import { Key } from './interface'

export function isDisabled<Raw extends Record<string, any>>(node: Raw): boolean {
  return node.disabled
}

export function isKey<Raw extends Record<string, any>>(node: Raw): Key {
  return node.key
}

export function isParentKey<Raw extends Record<string, any>>(node: Raw): Key {
  return node.parentKey
}

export function getChildren<Raw extends Record<string, any>>(node: Raw): Array<Raw> {
  return node.children
}

export function getLabel<Raw extends Record<string, any>>(node: Raw): string {
  return node.label
}

export function filter(keyword = '', label = '') {
  return label.toLowerCase().includes(keyword.toLowerCase())
}
